<template>
  <el-row>
    <el-col :span="24">
      <el-menu active-text-color="#white" class="el-menu-vertical-demo" :default-active="active" text-color="#333">
        <!-- 首页 -->
        <router-link :to="{ name: 'index' }">
          <el-menu-item index="1">
            <span>首页</span>
          </el-menu-item>
        </router-link>
        <!-- 分类管理 -->
        <router-link :to="{ name: 'student' }">
          <el-menu-item index="2">
            <span>学生管理</span>
          </el-menu-item>
        </router-link>
        <!-- 商品管理 -->
        <router-link :to="{ name: 'activity' }">
          <el-menu-item index="3">
            <span>活动管理</span>
          </el-menu-item>
        </router-link>
        <!-- 个人中心 -->
        <router-link :to="{ name: 'setting' }">
          <el-menu-item index="4">
            <span>个人中心</span>
          </el-menu-item>
        </router-link>
      </el-menu>
    </el-col>
  </el-row>
</template>

<script setup>
import { ref } from 'vue'
import router from '../router'
const menuIndex = {
  index: '1',
  category: '2',
  goods: '3',
  setting: '4'
}
const active = ref(menuIndex[router.currentRoute.value.name] || '0')
</script>

<style lang="scss" scoped>
.el-menu {
  border: 0 !important;

  .is-active {
    background: linear-gradient(90deg, #1493fa, #01c6fa) !important
  }

  a {
    text-decoration: none;
    color: white;
  }
}
</style>